package com.fit.pages.destination;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.annotations.AdminAccess;
import com.fit.annotations.UserAccess;
import com.fit.dao.destination.DestinationDAO;
import com.fit.entities.Destination;
import com.fit.pages.ErrorPage;

@AdminAccess
@UserAccess
public class AddDestination {
	
	@Property
	private Destination destination;

	@InjectPage
	private ErrorPage errorPage;

	@Inject
	private DestinationDAO destinationDAO;

	Object onSuccess() {
		errorPage.setMessage("");

		if (destinationDAO.save(destination)) {
			errorPage.setMessage("Destination successfully added");
			return errorPage;
		} else {
			errorPage.setMessage("Destination is null");
			return errorPage;

		}

	}

}
